package org.kadicon.android.file;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;

import org.kadicon.android.file.R;

import android.app.Activity;
import android.os.Bundle;

public class MyFile extends Activity {
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

		try {
			InputStream is = getAssets().open("ReadAssets.txt");

			int size = is.available();
			byte[] buffer = new byte[size];

			is.read(buffer);

			FileOutputStream sdcardFOS = new FileOutputStream(
					"/sdcard/WriteSDCard.txt");
			sdcardFOS.write(buffer);
			sdcardFOS.close();

			FileOutputStream localFilesFOS = openFileOutput(
					"WriteLocalFiles.txt", Activity.MODE_WORLD_WRITEABLE);
			localFilesFOS.write(buffer);
			localFilesFOS.close();

			is.close();

		} catch (IOException e) {
			// Should never happen!
			throw new RuntimeException(e);
		}
	}
}